package com.zzh.wsss.controller;

import com.zzh.wsss.pojo.Job;
import com.zzh.wsss.service.UserJobService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
//解决跨域
@CrossOrigin
public class UserJobController {
    @Autowired
    private UserJobService userJobService;


    @RequestMapping(value = "/getJobInfo",method = RequestMethod.GET)
    private Map<String,Object> getJobInfo(String username,String count){
        Map<String,Object> map=new HashMap<String, Object>();
        List<Job> list = userJobService.getJobs(username,count);
        map.put("jobs",list);
        Integer num=userJobService.getJobNum();
        map.put("num",num);
        return map;
    }

    @RequestMapping(value = "/jobApply",method = RequestMethod.POST)
    private Map<String,Object> userJobApply(@RequestBody Map<String,String> map){
        Map<String,Object> m=userJobService.userJobApply(map.get("username"),map.get("jobId"),map.get("action"),map.get("info"));
        return m;
    }

    @RequestMapping(value = "/getUserJobInfo",method = RequestMethod.GET)
    private Map<String,Object> getUserJobInfo(String jobId){
        Map<String,Object> map=userJobService.getUserJobInfo(jobId);
        return map;
    }



}
